const baseJs = require('../../common/base')
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    uid: wx.getStorageSync('uid'),
    Identity: '',//身份
    HeaderImage: '',//头像
    PartnerUserName: '',//手机号
    wangqiData: {
      OneEnterNum: 0,
      OneAllOrderMoney: 0,
      OneAvgOrderMoney: 0
    },
    jingdainData: {
      TwoEnterNum: 0,
      TwoAvgOrderMoney: 0,
      TwoAllOrderMoney: 0
    },
    tuijianData: {
      ThreeEnterNum: 0,
      ThreeAvgOrderMoney: 0,
      ThreeAllOrderMoney: 0
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.GetOverViewData()
  },

  //获得数据
  GetOverViewData() {
    wx.showLoading({
      title: '加载中',
    })
    wx.request({ //获得头像和手机号
      url: baseJs.api + baseJs.encryUrl("method=GetUserInfoByIDs&UID=" + this.data.uid),
      success: res => {
        var json = JSON.parse(baseJs.decryUrl(res.data)).ResultData;
        this.setData({
          HeaderImage: json.HeaderImage,
          PartnerUserName: json.PartnerUserName,
        })
        
      }
    })
    wx.request({ //获得收益码
      url: baseJs.api + baseJs.encryUrl("method=DeveloperOpenBusinessNumAndComeMaInfo&UID=" + this.data.uid),
      success: res => {
        var json = JSON.parse(baseJs.decryUrl(res.data)).ResultData[0]
        console.log(json);
        this.setData({
          Identity: json.Identity,
          wangqiData: {
            OneEnterNum: json.OneEnterNum,
            OneAllOrderMoney: json.OneAllOrderMoney,
            OneAvgOrderMoney: json.OneAvgOrderMoney
          },
          jingdainData: {
            TwoEnterNum: json.TwoEnterNum,
            TwoAvgOrderMoney: json.TwoAllOrderMoney,
            TwoAllOrderMoney: json.TwoAllOrderMoney
          },
          tuijianData: {
            ThreeEnterNum: json.ThreeEnterNum,
            ThreeAvgOrderMoney: json.ThreeAvgOrderMoney,
            ThreeAllOrderMoney: json.ThreeAllOrderMoney
          }
        })
        wx.hideLoading()
      }
    })
  }
})